package util;

import java.util.*;
/**
 *  Temperary class to store user data in until Database adds support.
 *
 */

public class UserData {
	private static boolean daysToGenerate[] = new boolean[7];
	private static HashSet<Long> skip;
	private static HashSet<Long> added;
	private static Calendar generatedTo=new GregorianCalendar();

	// WARNING, mutable.
	public static Calendar getGeneratedTo() {
		return generatedTo;
	}
	public static boolean shouldGenerate(int dayOfWeek) {
		return daysToGenerate[dayOfWeek-1];
	}
	public static void setDaysToGenerate(boolean [] days) {
		System.out.println(Arrays.toString(days));
		daysToGenerate=days;
	}

	public static boolean skip(Calendar cal) {
		cal.clear(Calendar.HOUR_OF_DAY);
		cal.clear(Calendar.MINUTE);
		cal.clear(Calendar.SECOND);
		cal.clear(Calendar.MILLISECOND);
		return skip.contains(cal.getTimeInMillis());
	}
	public static void addSkip(Calendar cal) {
		cal.clear(Calendar.HOUR_OF_DAY);
		cal.clear(Calendar.MINUTE);
		cal.clear(Calendar.SECOND);
		cal.clear(Calendar.MILLISECOND);
		skip.add(cal.getTimeInMillis());
	}
	public static void clean() {
		GregorianCalendar cal = new GregorianCalendar();
		cal.clear(Calendar.HOUR_OF_DAY);
		cal.clear(Calendar.MINUTE);
		cal.clear(Calendar.SECOND);
		cal.clear(Calendar.MILLISECOND);
		long today = cal.getTimeInMillis();
		Iterator<Long> iter = skip.iterator();
		while(iter.hasNext()) {
			long l = iter.next();
			if(l<today) iter.remove();
		}
	}
}
